package com.mengxuegu.springboot.config;

import com.mengxuegu.springboot.intercepter.MyIntercepter;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableWebMvc
@Configuration
public class MySpingmvcconfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {

        registry.addViewController("/").setViewName("main/index");
        registry.addViewController("/main.html").setViewName("main/system");

    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new MyIntercepter())
                .addPathPatterns("/")
                .excludePathPatterns("/css/*","/img/*","/js/*","/login","/main.html","/");
    }
}
